<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="team02.server.bean.UserBean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<link href="${pageContext.request.contextPath}/css/org_manager.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/add_new_org.css"
	rel="stylesheet" type="text/css" />
<jsp:useBean id="edittingUser"
	class="team02.server.bean.UserBean" scope="page"></jsp:useBean>
<%
//権限をチェックする
if(userBean.getAccessLevel()!=2){
	response.sendRedirect("404.html");
	return;
}%>
<script>
function check_selected()
{
	var test=document.getElementsByName("selected_id");
	var sizes=test.length;
	for(var i=0;i<sizes;i++)
		if(test[i].checked)
			return true;
	alert("一つのユーザを選択してください！");
	return false;
	
}
function check_delete(){
	if(check_selected())
		{
		if(confirm("本当にこのユーザを削除したいですか"))
			{
			return true;
			}
		}
	return false;
}
</script>
<div class="menu1"><%@include file="/jsputils/menu.jsp"%>
	<div class = "greeting_message">
		<%@include file="/jsputils/greeting.jsp"%>
	</div>
</div>
<div class="container" style="height:400px">
<c:set value="<%=userBean.listAllUser()%>" var="listUser"></c:set>
<form action="" method="post" name="form">
	<div class="menu">
		<p class="menu_label">ユーザ管理者</p>
		<p class="menu_item">
<%if(userBean.getOrg_status()==0)
{%>
			<button type="submit" formaction="user_add.t02">新規追加</button>
			<button type="submit" formaction="user_edit.t02" onclick="return check_selected()">編集</button>
			<button type="submit" formaction="user_delete.t02" onclick="return check_delete()">削除</button>
<%}%>
		</p>
	</div>
		<table style="width: 100%" class="table_content">
			<tr>
				<th></th>
				<th>名前</th>
				<th>ログイン名</th>
				<th>メール</th>
				<th>タイプ</th>
			</tr>
			<c:forEach var="userItem" items="${listUser}">
			<tr>
				<td><input type="radio" name="selected_id"
					value="${userItem.userId}"></td>
				<td>
				${userItem.name}
				</td>
				<td>
				${userItem.username }
				</td>
				<td>
				${userItem.email }
				</td>
				<td>
				${userItem.userType }
				</td>
			</tr>
			</c:forEach>
			
		</table>
</form>
</div>